package com.ylsk.check.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ylsk.check.domain.dto.CheckRecordDTO;
import com.ylsk.check.domain.so.CheckRecordSO;
import com.ylsk.check.domain.so.ReportInfoSO;
import com.ylsk.check.domain.vo.CheckRecordVO;
import com.ylsk.check.domain.vo.ReportInfoVO;
import com.ylsk.check.domain.vo.TodayCheckTaskVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.CheckRecord;
import com.ylsk.check.service.ICheckRecordService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 施工检查记录Controller
 *
 * @author yangsy
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/check/checkRecord")
public class CheckRecordController extends BaseController
{
    @Autowired
    private ICheckRecordService checkRecordService;

    /**
     * 查询施工检查记录列表
     */
    @PreAuthorize("@ss.hasPermi('check:checkRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckRecordSO checkRecordSO)
    {
        startPage();
        List<CheckRecordVO> list = checkRecordService.selectCheckRecordList(checkRecordSO);
        return getDataTable(list);
    }

    /**
     * 导出施工检查记录列表
     */
    @PreAuthorize("@ss.hasPermi('check:checkRecord:export')")
    @Log(title = "施工检查记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckRecordSO checkRecordSO)
    {
        List<CheckRecordVO> list = checkRecordService.selectCheckRecordList(checkRecordSO);
        ExcelUtil<CheckRecordVO> util = new ExcelUtil<CheckRecordVO>(CheckRecordVO.class);
        util.exportExcel(response, list, "施工检查记录数据");
    }

    /**
     * 获取施工检查记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:checkRecord:query')")
    @GetMapping(value = "/{checkRecordId}")
    public AjaxResult getInfo(@PathVariable("checkRecordId") Long checkRecordId)
    {
        return success(checkRecordService.selectCheckRecordByCheckRecordId(checkRecordId));
    }

    /**
     * 新增施工检查记录
     */
    @PreAuthorize("@ss.hasPermi('check:checkRecord:add')")
    @Log(title = "施工检查记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckRecordDTO checkRecordDTO)
    {
        return toAjax(checkRecordService.insertCheckRecord(checkRecordDTO));
    }

    /**
     * 修改施工检查记录
     */
    @PreAuthorize("@ss.hasPermi('check:checkRecord:edit')")
    @Log(title = "施工检查记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckRecordDTO checkRecordDTO)
    {
        return toAjax(checkRecordService.updateCheckRecord(checkRecordDTO));
    }

    /**
     * 删除施工检查记录
     */
    @PreAuthorize("@ss.hasPermi('check:checkRecord:remove')")
    @Log(title = "施工检查记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkRecordIds}")
    public AjaxResult remove(@PathVariable Long[] checkRecordIds)
    {
        return toAjax(checkRecordService.deleteCheckRecordByCheckRecordIds(checkRecordIds));
    }

    /**
     * 今日施工  不分页列表
     */
    @GetMapping("/selectTodayCheckTaskList")
    public AjaxResult selectTodayCheckTaskList(CheckRecordSO checkRecordSO)
    {
        List<TodayCheckTaskVO> list = checkRecordService.selectTodayCheckTaskList(checkRecordSO);
        return success(list);
    }
}
